Keep gating setup until an account actually exists - #1224
Conversation
Visiting /admin/setup latched setupCompleted=true before any superuser was created, so a second visit to the bare domain skipped the gate and landed on /admin/auth — a dead end on a never-set-up instance. Only latch once a real superuser exists; until then, redirect every non-setup admin page back to setup. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Team Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe admin route now separates setup redirection from setup completion tracking. It redirects only non-setup, non-file requests when setup is required. It sets ChangesAdmin setup flow
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to Fresh deployments remain in setup until a superuser exists, while setup pages and assets remain reachable and other admin pages redirect to setup. No current merge-blocking risk remains. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Problem
On a fresh deploy (no account yet), the bare domain correctly went to the setup screen the first time. But a second visit landed on
/admin/auth— a dead end, since the server was never set up and no account exists to sign in with.Cause
RegisterAdminApp'ssetupCompletedflag was latched totruein theelsebranch that also fires when serving/admin/setupitself (isSetup=truemakes the redirect condition false). So the very first request to the setup page marked setup "complete" before any superuser existed, and every later/admin/*request skipped the gate — letting the root page's redirect to/admin/authstick.Fix
Only latch
setupCompletedwhen a real superuser exists (!setupRequired). While setup is still required, redirect every non-setup, non-file/admin/*request back to/admin/setup, so an abandoned setup can't strand the instance at the auth dead-end.Verification
go build ./internal/✅🤖 Generated with Claude Code
Summary by CodeRabbit